from django.conf.urls import url
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token

from users import views
from users.views import MyObtainJSONWebToken

urlpatterns = [
    url(r'^test/$', views.TestView.as_view()),
    url(r'^test2/$', views.TestView2.as_view()),

    # 判断用户是否存在
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),
    # 注册用户
    url(r'^users/$', views.UserView.as_view()),
    # 查询用户详情信息
    url(r'^user/$', views.UserDetailView.as_view()),
    # 查询用户详情信息
    url(r'^email/$', views.EmailView.as_view()),
    # 查询用户详情信息
    url(r'^email/verification/$', views.VerifyEmailView.as_view()),


    # 登录接口
    # url(r'^authorizations/$', obtain_jwt_token),
    url(r'^authorizations/$', MyObtainJSONWebToken.as_view()),

    # 用户浏览历史记录
    url(r'^browse_histories/$', views.BrowseHistoryView.as_view()),
    url(r'^authorizations/$', views.UserAuthorizeView.as_view()),

]

router = routers.DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')

urlpatterns += router.urls